﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RadarA
{
    class MucTieu
    {
        public ToaDo _current;// điểm đầu
        public ToaDo _to;  // điểm cuối
        public string _category;// kiểu loai mục tiêu
        public int ID;
        public List<ToaDo> airline = new List<ToaDo>();// biến kiểu danh sách tọa độ
        public Color _color;
        public PointF CenterPoint;
        public MucTieu()
        { }
        public MucTieu(string loai, int id, List<ToaDo> qd, Color color)
        {
            ID = id;
            _category = loai;
            airline = qd;
            _current = qd[0];
            _to = qd[1];
            _color = color;
        }
        internal void DrawItem(RadaA1 radar, Graphics g, int sizeradar)  // dùng nội bộ vẽ hình mt
        {
            CenterPoint = new PointF(sizeradar / 2, sizeradar / 2);
            PointF cp = new PointF((float)_current.X, (float)_current.Y);
            //loai 3 - Hinh tam giac - Quan dich
            if (_category == "Quân sự (địch)")
            {

                PointF _topLeft = new PointF(cp.X - ((float)8 / 2), cp.Y - ((float)8 / 2));

                PointF p1 = new PointF(((float)_topLeft.X + ((float)8 / 2)), (float)_topLeft.Y);
                PointF p2 = new PointF((float)_topLeft.X, (float)_topLeft.Y + (float)8);
                PointF p3 = new PointF((float)_topLeft.X + (float)8, (float)_topLeft.Y + (float)8);

                GraphicsPath _gp = new GraphicsPath(FillMode.Winding);
                _gp.AddLine(p1, p2);
                //_gp.AddPolygon(new PointF[] { p1, p2, p3 });

                //string path = Directory.GetCurrentDirectory();
                //Image newIcon = Image.FromFile(pathIcon);

                //// Create rectangle for icon.

                Rectangle rect = new Rectangle(Convert.ToInt16(_current.X), Convert.ToInt16(_current.Y), 10, 10);
                Pen p = new Pen(Color.Red);
                p.Width = 3;
                //// Draw icon to screen.
                //g.DrawImage(newIcon, rect);

                PointF pnew1 = new PointF();
                PointF pnew2 = new PointF();
                pnew1 = p1;
                pnew2 = p1;


                /*if (_current.X>=0 && _current.X<=sizeradar/2 && _current.Y>= 0 && _current.Y<=sizeradar/2)
                {
                    pnew2.X += 5;
                    pnew2.Y -= 8;
                }
                if (_current.X>=0 && _current.X<=sizeradar/2 && _current.Y>= sizeradar/2 && _current.Y<=sizeradar)
                {
                    //pnew1.X += 5;
                    pnew2.X -= 5;
                    pnew2.Y -= 8;
                }
                if (_current.X >= sizeradar / 2 && _current.X <= sizeradar && _current.Y >= 0 && _current.Y <= sizeradar/2)
                {
                    pnew2.X += 5;
                    pnew2.Y += 8;
                }
                if (_current.X >= sizeradar / 2 && _current.X <= sizeradar && _current.Y >= sizeradar / 2 && _current.Y <= sizeradar)
                {
                    pnew2.X += 5;
                    pnew2.Y -=8;
                }*/
                //pnew1.X -= 5;
                //pnew2.Y += 5;

                g.DrawLine(p, pnew1, pnew2);
                //p1.X += 5;
                //p1.Y += 5;
                //p2.X += 3;
                //p2.Y += 3;
                //p.Color = Color.White;
                //if (clsCommons.bamsatmuctieu)
                //{
                //    g.DrawLine(p, p1, p2);
                //}
                g.DrawLine(p, p1, p2);
                /*GraphicsPath _gp = new GraphicsPath(FillMode.Winding);

                string path = Directory.GetCurrentDirectory();// đường dẫn tới hình mt
                Image newIcon = Image.FromFile(pathIcon);// tạo mới hình theo đường dẫn truyền v

                //// Create rectangle for icon.
                Rectangle rect = new Rectangle(Convert.ToInt16(_current.X), Convert.ToInt16(_current.Y), 20, 20);

                //// Draw icon to screen.
                g.DrawImage(newIcon, rect);*/
            }

        }
    }

}